package com.wk.springboot.listener;

import org.springframework.batch.core.ExitStatus;
import org.springframework.batch.core.StepExecution;
import org.springframework.batch.core.StepExecutionListener;
import org.springframework.stereotype.Component;

/**
 * @Classname MyStepExecutionListener
 * @Description 写一个自定义的stepExecution的监听
 * @Date 2020/4/2 14:27
 * @Author by weikai
 */
@Component
public class MyStepExecutionListener implements StepExecutionListener {

  @Override
  public void beforeStep(StepExecution stepExecution) {
    System.out.println("开始对一个step监听");
    System.out.println("开始，exitStatus："+stepExecution.getExitStatus());
    System.out.println("开始，stepName："+stepExecution.getStepName());
    System.out.println("开始，startTime："+stepExecution.getStartTime());
  }

  @Override
  public ExitStatus afterStep(StepExecution stepExecution) {
    System.out.println("结束对一个step监听");
    System.out.println("结束，exitStatus："+stepExecution.getExitStatus());
    System.out.println("结束，stepName："+stepExecution.getStepName());
    System.out.println("结束，endTime："+stepExecution.getEndTime());
    return ExitStatus.COMPLETED;
  }
}
